package com.parkinglot.util;

import org.springframework.stereotype.Component;

import java.util.Random;

@Component
public class CarNumberInit {
   public static String carinit() {

       String[] citys = {"无", "无", "无"};
       String sectionNamePre = "断面";
       while (true) {
           String sectionName = sectionNamePre + (new Random().nextInt(9000));    //断面：随机0-1999
           String city = citys[(new Random().nextInt(3))];//随机取津、京、宁
           StringBuffer plateNumStr = new StringBuffer(city);//下面开始：拼接车牌号，并随机产生0到9的6位车牌号
           plateNumStr.append(new Random().nextInt(10))
                   .append(new Random().nextInt(10))
                   .append(new Random().nextInt(10))
                   .append(new Random().nextInt(10))
                   .append(new Random().nextInt(10))
                   .append(new Random().nextInt(10));
           return plateNumStr.toString();
       }
   }
    public static void main(String[] args) {
        CarNumberInit carNumberInit=new CarNumberInit();
        System.out.println(carNumberInit.carinit());
    }
}